package com.roomio.domain;


import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

import com.roomio.core.security.model.User;


@NamedQueries(value={
		@NamedQuery(name="user.transaction.by.user",query="from UserTransaction ut where owner.id=:userId "),
		@NamedQuery(name="get.transaction.by.group.transaction",query="from UserTransaction ut where groupTransaction.id=:groupTransactionId ")
})

@Entity
@Table (name="USER_TRANSACTION")
public class UserTransaction extends Transaction {	
	
//	@ManyToOne(optional=true,fetch= FetchType.EAGER)
//	private Group groupId;
	
/*	@ManyToOne(fetch = FetchType.EAGER, cascade = { CascadeType.REFRESH })
	@JoinColumn(name = "USER_ID", nullable = false)
	private User user;	*/
	
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "GROUP_TRANSACTION_ID", nullable = true)
    private GroupTransaction groupTransaction;

 	

	public GroupTransaction getGroupTransaction() {
		return groupTransaction;
	}

	public void setGroupTransaction(GroupTransaction groupTransactionId) {
		this.groupTransaction = groupTransactionId;
	}
	
	public String toString() {
		return ReflectionToStringBuilder.toString(this,
				ToStringStyle.SHORT_PREFIX_STYLE);
	}
    
    
}
